using System;
using System.Collections.Generic;
using System.Text;
using Objects;

namespace DAL
{
    public class DALKhachHangNhanThe
    {
        public int Insert(KhachHangNhanThe Item)
        {
            clsDataAccess acc = new clsDataAccess();


            string[] sname = new string[] { "@Ten", "@GioiTinh", "@IdQuocTich", "@NgaySinh", "@CMND", "@NgayCap", "@IdTinhThanh", "@DiaChiThuongTru", "@DiaChiLienLac", "@Email", "@DienThoaiNha", "@DienThoaiDiDong", "@GhiChu", "@Status", "@SapXep" };
            string[] vname = new string[] { Item.Ten.ToString(), Item.GioiTinh.ToString(), Item.IdQuoctich.ToString(), Item.NgaySinh.ToString(),Item.CMND.ToString(), Item.NgayCap.ToString(),
                                                                Item.IdTinhThanh.ToString(), Item.DiaChiThuongTru.ToString(), Item.DiaChiLienLac.ToString(), Item.Email.ToString(), Item.DienThoaiNha.ToString(),Item.DienThoaiDiDong.ToString(), Item.GhiChu.Trim(), Common.Myconst.HOATDONG.ToString(), Item.SapXep.ToString()};
            return acc.InsertUpdateDetete("KhachHangNhanThe_Insert", sname, vname);

        }


        public KhachHangNhanThe GetMaxId()
        {
            clsDataAccess acc = new clsDataAccess();
            string[] sname = new string[] { "@Status" };
            string[] vname = new string[] { Common.Myconst.HOATDONG.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("KhachHangNhanThe_GetMaxId", sname, vname);
            KhachHangNhanThe Item = new KhachHangNhanThe();

            System.Data.DataRow dr = ds.Tables[0].Rows[0];
            return Item.Populate(dr);
        }

        public KhachHangNhanThe GetById(int Id)
        {
            clsDataAccess acc = new clsDataAccess();
            string[] sname = new string[] { "@Id" };
            string[] vname = new string[] { Id.ToString() };
            System.Data.DataSet ds = acc.CommandSelect("KhachHangNhanThe_GetById", sname, vname);
            KhachHangNhanThe Item = new KhachHangNhanThe();

            System.Data.DataRow dr = ds.Tables[0].Rows[0];
            return Item.Populate(dr);
        }
    }
}
